package com.metacube.metaconnect.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.metacube.metaconnect.Service.UserInformationService;
import com.metacube.metaconnect.model.SignUpStep1Form;
import com.metacube.metaconnect.model.UserInformationDAO;

public class SignUpStep1Action extends Action {

	/*
	 * insert the data of user to userinformation table in database
	 */
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		SignUpStep1Form step1form = (SignUpStep1Form) form;

		boolean result = new UserInformationService()
				.insertUserInfoStep1(step1form);

		if (result) {
			request.getSession().setAttribute("signupstep2",
					step1form.getEmail());
			request.getSession().setAttribute("emailId", step1form.getEmail());
			request.getSession().removeAttribute("signupstep1");
			return mapping.findForward("success");
		} else
			return mapping.findForward("failure");
	}
}
